package xyz.suancaiyu;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/**
 * 《Spring Boot实战》第八章.
 * <p>
 * 生成可部署在Tomcat等应用容器中运行的war文件.
 * <p>
 * 首先:
 * 1.pom.xml 设置<pakaging>war</pakaging>;
 * 2.继承SpringBootServletInitializer重写configure方法,参考{@link xyz.suancaiyu.ReadingListServletInitializer};
 * 3.使用idea中maven的war:war生成war文件.
 * <p>
 * Created by puruidong on 2017/10/1.
 */
@SpringBootApplication
public class ReadingListApplication extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(ReadingListApplication.class, args);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("login");
    }

    @Override
    public void addArgumentResolvers(
            List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(new ReaderHandlerMethodArgumentResolver());
    }


}
